<@t.plat_body pageid="clazzs">
<script type="text/javascript" src="${base}/js/plugins/datatables/datatables.min.js"></script>
<script type="text/javascript" src="${base}/js/plugins/datatables/datatables_basic.js"></script>
<script type="text/javascript" src="${base}/js/excellentexport.js"></script>
<script type="text/javascript" src="${base}/js/plugins/selects/select2.min.js"></script>
<style>
    .table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{
        padding: 4px;
    }
    .form-control{
        height: 28px;
    }
    .datatable-header, .datatable-footer{
        padding-top: 0px;
    }
</style>
<div class="panel panel-flat">
    <div class="panel-heading">
        <h5 class="panel-title">班级管理</h5>
        <div class="heading-elements">
        </div>
    </div>

    <div class="panel-body" >
        <table class="listTable table table-striped table-bordered dataTable" id="userTable">
        </table>
    </div>
</div>
<script>
    function delRec(id) {
        createConfirm('您确定要删除该数据',function() {
            post('pl/info/del_class?id='+id,function (result) {
                if(result.code==0){
                    table.ajax.reload();
                }else{
                    alertError(result.message);
                }
            });
        });
    }
    var result_data=[]
    function export_classz() {
        var index = layer.msg('正在处理，请稍后...', {
            icon: 16
            ,time:1000000000
            ,shade: [0.3,'#000000']
        });
        result_data=[];
        get('pl/info/list_class?limit=10000',function (result) {
            if(result.data.length==0){
                layer.close(index);
                alertError('没有数据可导出');
                return
            }
            result_data.push(['名称','是否毕业','创建时间']);
            result.data.map(function (value,i) {
                result_data.push([value.name,((value.graduation==0)?'否':'是'),new Date(value.createtime).format('yyyy-MM-dd hh:mm:ss')]);
            });
            setTimeout(function () {
                $('.layui-layer-content').html('导出成功，点击下载文件<a href="#" onclick="return ExcellentExport.convert({anchor: this, filename: \'班级\', format: \'xlsx\'}, [{name: \'班级列表\',from: {array: result_data}}])" style="color: #4fc3f7;font-style: normal" id="saveys-number">下载</a>，或者取消下载<a href="#" onclick="layer_close_all()">取消</a>');
            },1000)
        },10000000000)
    }

    var table;
    $(function () {
        table=simpleTable('userTable', [
            {
                sWidth:80,
                dataIndex: 'name',
                title: "名称"
            },
            {
                sWidth:80,
                dataIndex: 'graduation',
                title: "是否毕业",
                render:function (data) {
                    return (data==0)?"否":"是";
                }
            },{
                sWidth:140,
                dataIndex: 'createtime',
                title: "创建时间",
                type:'date'
            },
            {
                sWidth:200,
                title: "操作",
                dataIndex: 'id',
                sClass:'text-center',
                render: function (data, type, full) {
                    var html = '<div>';
                    html+='<a style="margin-left: 2px" href="javascript:void(0)" onclick="dialogBox(\'${base}/plat/info/clazzs_edit?id='+data+'\', \'编辑\', 450, 350);" class="btn btn-success btn-xs btn-outline">编辑</a>';
                    html+='<a href="javascript:void(0)" style="margin-left: 2px" onclick="delRec(\''+data+'\')" class="btn btn-danger btn-xs btn-outline">删除</a>'
                    html+='<a style="margin-left: 2px" href="javascript:void(0)" onclick="dialogBox(\'${base}/plat/info/class_infos?type=1&classid='+data+'\', \'学生信息\', 800, 600);" class="btn bg-purple-400 btn-xs btn-outline">查看学生</a>';
                    html+='</div>';
                    return html;
                }
            }
        ], {
            bAutoWidth:false,
            searching: true,
            bLengthChange: false,
            bSort: false,
            url: '${base}/pl/info/list_class?limit=10000',
            pageLength: 10
        });

        $("div.datatable-toolbar").html('<form class="pull-right navbar-left" id="searchForm">' +
                '<a href="${base}/plat/info/clazzs_im" style="margin-left: 2px" class="btn btn-primary">导入</a>' +
                '<a href="#" onclick="export_classz()" style="margin-left: 12px" class="btn btn-success">导出</a>' +
                '</form>');
        $('.dataTables_length select,.datatable-toolbar select').select2({
            minimumResultsForSearch: "-1"
        });
    });





</script>
</@t.plat_body>
